﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZhouYu.DreamTour.BLL.IService;
using ZhouYu.DreamTour.DAL.IRepository;
using ZhouYu.DreamTour.Model;
using ZhouYu.DreamTour.ViewModel;

namespace ZhouYu.DreamTour.BLL.Service
{
    public class ScenicService: IScenicService
    {
        private IScenicRepository _scenicRepository;
        public ScenicService(IScenicRepository scenicRepository)
        {
            _scenicRepository = scenicRepository;
        }

        #region 获取单一主图片集合
        /// <summary>
        /// 获取单一主图片集合
        /// </summary>
        /// <returns></returns>
        public ResponseResult GetScenicPicList()
        {
            //创建响应结果类对象
            ResponseResult responseResult = new ResponseResult();
            //调用获取单一主图片集合
            responseResult.data = _scenicRepository.GetScenicPicList();
            return responseResult;
            
           
        }
        #endregion

        #region 查询旅游路线集合
        /// <summary>
        /// 查询旅游路线集合
        /// </summary>
        /// <returns></returns>
        public ResponseResult GetScenicExhibitions()
        {
            //创建响应结果类对象
            ResponseResult responseResult = new ResponseResult();
            //调用查询旅游路线集合
            responseResult.data = _scenicRepository.GetScenicExhibitions();
            return responseResult;
           
           
        }
        #endregion

        #region 查询首页景点
        /// <summary>
        /// 查询首页景点
        /// </summary>
        /// <returns></returns>
        public ResponseResult GetScenicFromIndex()
        {
            //创建响应结果类对象
            ResponseResult responseResult = new ResponseResult();
            //按条件取出旅游景点
            responseResult.data = _scenicRepository.GetScenicExhibitions().Skip(3).Take(4);
            return responseResult;


        }
        #endregion

        #region 根据主图查询次图
        /// <summary>
        /// 根据主图查询次图
        /// </summary>
        /// <returns></returns>
        public ResponseResult GetPicListById(int Pic_Id)
        {
            //创建响应结果类对象
            ResponseResult responseResult = new ResponseResult();
            //调用根据主图查询次图
            responseResult.data= _scenicRepository.GetPicListById(Pic_Id);
            return responseResult;
           
           
        }
        #endregion

        #region 根据ID查询具体旅游景点详情
        /// <summary>
        /// 根据ID查询具体旅游景点详情
        /// </summary>
        /// <returns></returns>
        public ResponseResult GetScenicDetails(int TouristRouteId)
        {
            //创建响应结果类对象
            ResponseResult responseResult = new ResponseResult();
            //调用根据ID查询具体旅游景点详情
            responseResult.data = _scenicRepository.GetScenicDetails(TouristRouteId);
            return responseResult;
        }
        #endregion

        #region 查询景点的注意事项
        /// <summary>
        /// 查询景点的注意事项
        /// </summary>
        /// <returns></returns>
        public ResponseResult GetBeCarefulInfo(int BeCarefulInfoId)
        {
            //创建响应结果类对象
            ResponseResult responseResult = new ResponseResult();
            //调用查询景点的注意事项
            responseResult.data = _scenicRepository.GetBeCarefulInfo(BeCarefulInfoId);
            return responseResult;
        }
        #endregion

        #region 根据条件查询路线景点
        /// <summary>
        /// 根据条件查询路线景点
        /// </summary>
        /// <returns></returns>
        public ResponseResult SelScenicByPrice(int PriceOne, int PriceTwo, int Duration, string Certification,string OutPlace)
        {
            //创建响应结果类对象
            ResponseResult responseResult = new ResponseResult();
            //按价格查询景点
            //查询单个价格以下的数据
            if (PriceOne > 0 && PriceTwo <= 0)
            {
                responseResult.data = _scenicRepository.GetScenicExhibitions().Where(a => a.Price<PriceOne);
                return responseResult;
            }
            //查询单个价格以上的数据
            if (PriceOne <= 0 && PriceTwo > 0)
            {
                responseResult.data = _scenicRepository.GetScenicExhibitions().Where(a => a.Price >PriceTwo);
                return responseResult;
            }
            //按持续时长查询
            if (Duration>0)
            {
                responseResult.data = _scenicRepository.GetScenicExhibitions().Where(a => a.Duration==Duration);
                return responseResult;
            }
            //按景点等级查询
            if (!string.IsNullOrEmpty(Certification))
            {
                responseResult.data = _scenicRepository.GetScenicExhibitions().Where(a => a.Certification == Certification);
                return responseResult;
            }
            //按出发地点查询
            if (!string.IsNullOrEmpty(OutPlace))
            {
                responseResult.data = _scenicRepository.GetScenicExhibitions().Where(a => a.OutPlace == OutPlace);
                return responseResult;
            }
            //查询两个价格之间的数据
            responseResult.data = _scenicRepository.GetScenicExhibitions().Where(a=>a.Price>=PriceOne&&a.Price<=PriceTwo);
            return responseResult;


        }
        #endregion
    }
}
